const moviesModel = require("../models/moviesModel");

module.exports = {
    //增加电影
    async addMoives({
        cname,
        ename,
        types,
        area,
        poster,
        time,
        upDate,
        score,
        count,
        intro,
        isClassic,
        director,
        actor,
        images
    }) {
        return await moviesModel.create({
            cname,
            ename,
            types,
            area,
            poster,
            time,
            upDate,
            score,
            count,
            intro,
            isClassic,
            director,
            actor,
            images
        });
    },

    //查询所有
    async queryMoives() {
        return await moviesModel.find().exec();
    },

    //查询电影ID
    async queryOnlys(
        id,
    ) {
        return await moviesModel.findOne(
            {'_id':id}
        ).exec();
    },

    //查询电影类型type
    async queryTypeMoives(
        types,
    ) {
        return await moviesModel.find(
            types
        ).exec();
    },



    //删除
    async deleteMoives({
        cname,
    }) {
        return await moviesModel.deleteOne({
            cname,
        }).exec();
    },

    //修改
    async updateMoives({
        _id,
        cname,
        ename,
        types,
        area,
        poster,
        time,
        upDate,
        score,
        count,
        intro,
        isClassic,
        director,
        actor,
        images
    }) {
        return await moviesModel.updateOne(
            { _id }, {
            cname,
            ename,
            types,
            area,
            poster,
            time,
            upDate,
            score,
            count,
            intro,
            isClassic,
            director,
            actor,
            images
        }
        ).exec();
    },
}
